#include<bits/stdc++.h>
using namespace std;
const int N=5000001;

int n,p;
int arr[N];
int b[N];

int main()
{
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
	}
	memset(b,0,sizeof(b));
	for(int i=0;i<p;i++)
	{
		int l,r,s;
		scanf("%d%d%d",&l,&r,&s);
		b[l]+=s;
		b[r+1]-=s;
	}
	int mins=arr[1]+b[1];
	//int ans=
	for(int i=2;i<=n;i++)
	{
		b[i]=b[i]+b[i-1];
		arr[i]+=b[i];
		mins=min(mins,arr[i]);
	}
	printf("%d",mins);
	return 0;
}
